﻿$(document).ready(function (){
	var gender = "male";
	
	$("#chooseMale").click(function(){
		gender = "male";
	});	
	
	$("#chooseFemale").click(function(){
		gender = "female";
	});	
	
	$("#chooseGenerate").click(function(){
		var name = 	$("#nickname").attr("value");
		var g = 0;
		if(gender == "male"){
			g = 1;
		}else{
			g = 2;
		}
		$.ajax({
			type:"GET",
			url:"index/addrobot/robotName/"+name+"/gender/"+g,
			async:true,
			beforeSend:function loading(){
			},
			success:function(v){
				var data = window.JSON.parse(v);
				if(!data.success) {
					if(data.message == "needlogin") {
						window.location.href="login.html";
					}					
				} else {
					window.location.href="alanstreet.html";
				}
			},
			error:function(){
				alert("error!");
			}
		});		
	});		
});